package com.zbw;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.net.URL;

/*多线程：演示单线程和多线程下载图片*/
public class ThreadLoadImg extends Thread{
    public static void main(String args[]){
        ThreadLoadImg tm=new ThreadLoadImg();
        tm.start();
    }
    @Override
    public void run(){
        String url="https://img-baofun.zhhainiao.com/market/133/3760b2031ff41ca0bd80bc7a8a13f7bb_preview.mp4";
        downloadImg(url,"大大的文件");
        System.out.println("下载完成");

    }

    public void downloadImg(String url,String imgName){
        try{
            FileUtils.copyURLToFile(new URL(url),new File(imgName));
        }catch (Exception ex){
            ex.printStackTrace();
        }
    }
}

